#ifndef CONNECTDIALOG_H
#define CONNECTDIALOG_H

#include <QDialog>
#include <QScopedPointer>

class QLineEdit;
class QComboBox;
class QPushButton;
class QCheckBox;
class QSpinBox;
class QLabel;
class QFormLayout;
class QVBoxLayout;
class QHBoxLayout;
class QGroupBox;

class ConnectDialog : public QDialog
{
    Q_OBJECT

public:
    explicit ConnectDialog(QWidget *parent = nullptr);
    ~ConnectDialog();

    // 获取连接参数
    QString getHost() const;
    int getPort() const;
    QString getUsername() const;
    QString getPassword() const;
    QString getDomain() const;
    QString getProtocol() const;

private slots:
    void browseKeyFile();
    void testConnection();
    void accept() override;
    void reject() override;
    void protocolChanged(int index);

private:
    void setupUI();
    void loadSettings();
    void saveSettings();
    void validateInput();
    
    // UI元素
    QLineEdit *hostLineEdit;
    QSpinBox *portSpinBox;
    QLineEdit *usernameLineEdit;
    QLineEdit *passwordLineEdit;
    QLineEdit *domainLineEdit;
    QComboBox *protocolComboBox;
    QLineEdit *keyFileLineEdit;
    QPushButton *browseButton;
    QCheckBox *rememberPasswordCheckBox;
    QPushButton *testButton;
    QPushButton *connectButton;
    QPushButton *cancelButton;
    
    // 布局
    QFormLayout *formLayout;
    QVBoxLayout *mainLayout;
    QHBoxLayout *buttonLayout;
    QGroupBox *authGroupBox;
};

#endif // CONNECTDIALOG_H